home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST9-25.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  975b  |  39 lines

  1. ;
  2. ; *** Listing 9-25 ***
  3. ;
  4. ; Performs binary-to-ASCII conversion of a byte value
  5. ; by using DIV.
  6. ;
  7.     jmp    Skip
  8. ;
  9. ResultString    db    3 dup (?)
  10. ResultStringEnd    label    byte
  11.     db    0    ;a zero to mark the string end
  12. ;
  13. Skip:
  14. BYTE_VALUE=0
  15.     call    ZTimerOn
  16.     rept    100
  17.     mov    cx,(10 shl 8)+'0'
  18.             ;CL='0', used for converting to ASCII
  19.             ; CH=10, used for dividing by 10
  20.     mov    di,offset ResultString
  21.     mov    al,BYTE_VALUE
  22.     sub    ah,ah    ;prepare 16-bit dividend
  23.     div    ch    ;put least significant decimal
  24.             ; digit of BYTE_VALUE in AH,
  25.             ; other digits in AL
  26.     add    ah,cl    ;make it an ASCII digit
  27.     mov    [di+2],ah ;save least significant digit
  28.     sub    ah,ah    ;prepare 16-bit dividend
  29.     div    ch    ;put middle decimal digit in AL
  30.     add    ah,cl    ;make it an ASCII digit
  31.     mov    [di+1],ah ;save middle ASCII decimal digit
  32.             ;most significant decimal
  33.             ; digit is in AL
  34.     add    al,cl    ;make it an ASCII digit
  35.     mov    [di],al    ;save most significant digit
  36. BYTE_VALUE=BYTE_VALUE+1
  37.     endm
  38.     call    ZTimerOff
  39.